import store from "./store";

let actionContent = {
    moduleId: null,
    moduleType: null,
    path: null,
    status: true,
    visible: null,
    type: null,
    lock: null,
    value: null,
    menu: null,
    url: null,
    roleAdminStatus: null,
    roleClientStatus:null,
    roleUserStatus:null,
    inserted:null
};

export function action(e){
    let arr = e.split('&');
    actionContent = {
        type: 'action',
        moduleType: arr[0],
        moduleId: arr[1],
        menu: null,
        path: null,
        lock: null,
        value: null,
        url: null,
        status: true
    }
    console.log("moduleComponent2020:",actionContent)
    store.dispatch(actionContent);
}

//当点击后台管理模块时，触发manage(e)，点击自定义模块时不传值，即path == null
export function manage(e){
    actionContent = {
        type: 'manage',
        path: e
    }
    store.dispatch(actionContent);
}

//当点击侧边栏自定义模块层级时，将menu节点push到store, 由recursive()函数触发
export function menu(e){
    console.log("e:",e)
    actionContent = {
        type: 'menu',
        menu: e
    }
    store.dispatch(actionContent);
}

export function pushUrl(e) {
    console.log("addButton()",e)
    actionContent = {
        type: 'pushUrl',
        url: e,
    }
    store.dispatch(actionContent)
}

export function closeStatus() {
    actionContent = {
        type: 'closeStatus',
        status: false
    }
    store.dispatch(actionContent);
}

export function openStatus() {
    actionContent = {
        type: 'closeStatus',
        status: true
    }
    store.dispatch(actionContent);
}

export function closeRoleAdminStatus() {
    actionContent = {
        type: "closeRoleAdminStatus",
        roleAdminStatus: false
    }
    store.dispatch(actionContent);
}

export function closeRoleClientStatus() {
    actionContent = {
        type: "closeRoleClientStatus",
        closeRoleClientStatus: false
    }
    store.dispatch(actionContent);
}

export function modalRef(e) {
    alert(e)
    actionContent = {
        type: "modalRef",
        container:e,
    }
    store.dispatch(actionContent);
}

export function breadCrumbList(e) {
    actionContent = {
        type: "breadCrumbList",
        breadCrumbList:[e],
    }
    store.dispatch(actionContent);
}

export function addBreadCrumbList(e) {

    actionContent = {
        type: "addBreadCrumbList",
        addBreadCrumbList:e,
    }
    store.dispatch(actionContent);
}

export function inserted(e) {
    actionContent = {
        type: "inserted",
        inserted:e
    }
    store.dispatch(actionContent);
}

